<template>
  <div>
    <div class="container">
      <div class="handle-box">
        <el-select v-model="query.case_source" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件来源" class="handle-select mr10">
          <el-option key="1" label="市场查获" value="市场查获"></el-option>
          <el-option key="2" label="投诉举报" value="投诉举报"></el-option>
          <el-option key="3" label="上级交办" value="上级交办"></el-option>
        </el-select>
        <el-select v-model="query.case_type" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" clearable placeholder="案件性质" class="handle-select mr10">
          <el-option key="1" label="一般案件" value="一般案件"></el-option>
          <el-option key="2" label="简易案件" value="简易案件"></el-option>
        </el-select>
        <el-input v-model="query.case_number" placeholder="立案编号" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)" class="handle-input mr10"></el-input>
        <el-button type="primary" :icon="Search" @change="handleSearch(query.case_number,query.tcs_note_id,query.case_source,query.case_type)">搜索</el-button>
      </div>
      <el-table :data="tableList" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="case_source" label="案件来源" align="center"></el-table-column>
        <el-table-column prop="case_number" label="立案编号" width="200"  align="center"></el-table-column>
        <el-table-column prop="case_update_time" label="更新时间"  align="center"></el-table-column>
        <el-table-column prop="case_type" label="案件性质" align="center"></el-table-column>
        <el-table-column prop="date_of_filing" label="立案日期"  align="center"></el-table-column>
        <el-table-column label="证据先行保存通知书状态" align="center" width="180">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '证据采集已完成' ">
              <el-tag :type=" 'danger'">证据采集已完成 </el-tag>
            </div>
            <div v-if="scope.row.tcs_note_id === '证据先行保存通知书上传已完成' ||
            scope.row.tcs_note_id === '喷码记录表已完成' ||
            scope.row.tcs_note_id === '立案报告表已完成' ||
            scope.row.tcs_note_id === '立案报告表审核已完成' ||
            scope.row.tcs_note_id === '卷烟鉴别书已完成' ||
            scope.row.tcs_note_id === '涉案烟草价品核案表完成' ||
            scope.row.tcs_note_id === '询问笔录已完成' ||
            scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录询问确认'||
            scope.row.tcs_note_id === '立案报告表主任审核已完成'||
            scope.row.tcs_note_id ==='卷烟鉴别书已送检'||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='喷码记录表填写开始'||
            scope.row.tcs_note_id ==='喷码记录表填写完成'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'||
            scope.row.tcs_note_id ==='卷烟鉴别抽样单填写开始'||
            scope.row.tcs_note_id ==='卷烟鉴别委托书填写开始'||
            scope.row.tcs_note_id ==='上传送检结果开始'">
              <el-tag :type=" 'success'">已完成 </el-tag>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="下一步操作" width="300" align="center">
          <template #default="scope">
            <div v-if="scope.row.tcs_note_id === '证据采集已完成' ">
              <el-button text :icon="Upload" class="blue" @click="advice_note_tabel(scope.row)" >
                证据先行保存通知书上传
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '证据先行保存通知书上传已完成' ||
            scope.row.tcs_note_id === '喷码记录表已完成' ||
            scope.row.tcs_note_id === '立案报告表已完成' ||
            scope.row.tcs_note_id === '立案报告表审核已完成' ||
            scope.row.tcs_note_id === '卷烟鉴别书已完成' ||
            scope.row.tcs_note_id === '涉案烟草价品核案表完成' ||
            scope.row.tcs_note_id === '询问笔录已完成' ||
            scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录询问确认'||
            scope.row.tcs_note_id === '立案报告表主任审核已完成'||
            scope.row.tcs_note_id ==='卷烟鉴别书已送检'||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='喷码记录表填写开始'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'||
            scope.row.tcs_note_id ==='卷烟鉴别抽样单填写开始'||
            scope.row.tcs_note_id ==='卷烟鉴别委托书填写开始'||
            scope.row.tcs_note_id ==='上传送检结果开始'">
              <el-button text :icon="Folder" class="blue" @click="ratification_tabel_2(scope.row)" >
                查看证据先行保存批准书
              </el-button>
            </div>
            <div v-if="scope.row.tcs_note_id === '证据先行保存通知书上传已完成' ||
            scope.row.tcs_note_id === '喷码记录表已完成' ||
            scope.row.tcs_note_id === '立案报告表已完成' ||
            scope.row.tcs_note_id === '立案报告表审核已完成' ||
            scope.row.tcs_note_id === '卷烟鉴别书已完成' ||
            scope.row.tcs_note_id === '涉案烟草价品核案表完成' ||
            scope.row.tcs_note_id === '询问笔录已完成' ||
            scope.row.tcs_note_id === '已完成' ||
            scope.row.tcs_note_id === '无证经营公示已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录已完成' ||
            scope.row.tcs_note_id === '现场勘验笔录询问确认'||
            scope.row.tcs_note_id === '立案报告表主任审核已完成'||
            scope.row.tcs_note_id ==='卷烟鉴别书已送检'||
            scope.row.tcs_note_id ==='调查终结文书已完成'||
            scope.row.tcs_note_id ==='案件处理审批已开始'||
            scope.row.tcs_note_id ==='集体讨论已开始'||
            scope.row.tcs_note_id ==='集体讨论已完成'||
            scope.row.tcs_note_id ==='听证已开始'||
            scope.row.tcs_note_id ==='听证告知书已完成'||
            scope.row.tcs_note_id ==='听证已完成'||
            scope.row.tcs_note_id ==='案件处理审批已完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书确认完成'||
            scope.row.tcs_note_id ==='行政处罚事先告知书已完成'||
            scope.row.tcs_note_id ==='行政处罚决定书确认完成'||
            scope.row.tcs_note_id ==='行政处罚决定书已完成'||
            scope.row.tcs_note_id ==='行政罚款收据上传完成'||
            scope.row.tcs_note_id ==='行政罚款收据已完成'||
            scope.row.tcs_note_id ==='结案报告表已完成'||
            scope.row.tcs_note_id ==='喷码记录表填写开始'||
            scope.row.tcs_note_id ==='撤案集体讨论准备'||
            scope.row.tcs_note_id ==='撤案集体讨论已开始'||
            scope.row.tcs_note_id ==='卷烟鉴别抽样单填写开始'||
            scope.row.tcs_note_id ==='卷烟鉴别委托书填写开始'||
            scope.row.tcs_note_id ==='上传送检结果开始'
            ">
              <el-button text :icon="Document" class="blue" @click="advice_note_views(scope.row)" >
                查看先行保存通知书
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
            background
            layout="total, prev, pager, next"
            :current-page="query.pageIndex"
            :page-size="query.pageSize"
            :total="pageTotal"
            @current-change="handlePageChange"
        ></el-pagination>
      </div>
    </div>


    <el-dialog title="证据先行保存批准书填写" v-model="Ratification_Visible_1" width="70%" >
      <el-table :data="evidence_case_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="case_id" label="案件号"  align="center"></el-table-column>
        <el-table-column prop="evi_id_number" label="证据先行保存批准书编号"  width="200" align="center"></el-table-column>
        <el-table-column prop="tce_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="tce_amount" label="烟草价值"  align="center"></el-table-column>
        <el-table-column label="操作" width="220" align="center">
          <template #default="scope">
            <el-button text :icon="Edit" @click="ratification_edit(scope.row)" >
              查 看
            </el-button>
            <el-button text :icon="Edit" @click="create_evi_word(scope.row)" >
              打 印
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <template #footer>
				<span class="dialog-footer">

					<el-button @click="Ratification_Visible_1 = false">取 消</el-button>
          <el-button type="primary" @click="certern_ratification">确 定</el-button>
				</span>
      </template>
    </el-dialog>


    <el-dialog title="证据先行保存批准书填写" v-model="Ratification_Visible_2" width="70%" >
      <el-table :data="evidence_case_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="case_id" label="案件号"  align="center"></el-table-column>
        <el-table-column prop="evi_id_number" label="证据先行保存批准书编号"  width="200" align="center"></el-table-column>
        <el-table-column prop="tce_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="tce_amount" label="烟草价值"  align="center"></el-table-column>
        <el-table-column label="操作" width="220" align="center">
          <template #default="scope">
            <el-button text :icon="Edit" @click="ratification_view(scope.row)">
              查 看
            </el-button>
            <el-button text :icon="Printer" @click="create_evi_word(scope.row)" >
              打 印
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Ratification_Visible_2 = false">取 消</el-button>
          <el-button type="primary" @click="Ratification_Visible_2 = false">确 定</el-button>
				</span>
      </template>
    </el-dialog>

    <el-dialog title="证据先行保存批准书信息修改及确认" v-model="Ratification_Edit_Visible" width="34%">
      <el-form label-width="140px">
        <el-form-item label="商户烟草售卖许可证" >
          <el-select v-model="case_evi_data.mer_id"
                     clearable filterable placeholder="请选择涉嫌案由" >
            <el-option
                v-for="item in mer_Data"
                :key="item.mer_id"
                :label="item.retail_licence_code"
                :value="item.mer_id"
            >商户名称：{{item.mer_name}}}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="立案时间" >
          <el-date-picker v-model="case_evi_data.date_of_filing" type="datetime" placeholder="选择案发日期" value-format="YYYY-MM-DD HH:mm:ss">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="证据先行保存通知书编号" >
          <el-input v-model="case_evi_data.evi_id_number" ></el-input>
        </el-form-item>
        <el-form-item label="案由" >
          <el-select v-model="case_evi_data.tlc_id"
                     clearable filterable placeholder="请选择涉嫌案由" >
            <el-option
                v-for="item in illegal_Data"
                :key="item.tlc_id"
                :label="item.illegal_behavior"
                :value="item.tlc_id"
            >案由：{{item.illegal_behavior}} 级别：{{item.grade}}
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="涉案烟草种类数目" >
          <el-input v-model="case_evi_data.tce_type_number" disabled ></el-input>
        </el-form-item>
        <el-form-item label="涉案烟草总数" >
          <el-input v-model="case_evi_data.tce_number" disabled ></el-input>
        </el-form-item>
        <el-form-item label="先行保存地址" >
          <el-input v-model="case_evi_data.tce_address"  ></el-input>
        </el-form-item>
        <el-form-item label="承办人" >
          <el-select v-model="case_evi_data.user_id_1"
                     clearable filterable placeholder="请选择承办人" >
            <el-option
                v-for="item in staff_Data"
                :key="item.staff_id"
                :label="item.staff_name"
                :value="item.staff_id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="同行人" >
          <el-select v-model="case_evi_data.user_id_2"
                     clearable filterable placeholder="请选择承办人" >
            <el-option
                v-for="item in staff_Data"
                :key="item.staff_id"
                :label="item.staff_name"
                :value="item.staff_id"
            ></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-table :data="evidence_ciga_Data" border class="table" ref="multipleTable" header-cell-class-name="table-header">
        <el-table-column prop="ciga_variety" label="烟草种类"  align="center"></el-table-column>
        <el-table-column prop="ciga_model" label="烟草规格"  align="center"></el-table-column>
        <el-table-column prop="evi_number" label="烟草数量"  align="center"></el-table-column>
        <el-table-column prop="inkjet" label="烟草喷码"  align="center"></el-table-column>
        <el-table-column prop="evi_id_number" label="证据先行保存通知书编号"  align="center"></el-table-column>
      </el-table>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Ratification_Edit_Visible = false">取 消</el-button>
          <el-button type="primary" :icon="Document" @click="ratification_view_2" >预 览</el-button>
					<el-button type="primary" @click="edit_case_evidenct_data">保 存</el-button>
				</span>
      </template>
    </el-dialog>

    <!--    //查看证据先行保存批准书-->
    <el-dialog title="" v-model="Ratification_View_Visible" width="34%">
      <html>
      <head>
        <title>证据先行保存批准书</title>
      </head>
      <body>
      <h1 align="center">
        福建省闽侯县烟草专卖局
      </h1>
      <h2 align="center">
        证据先行保存批准书
      </h2>
      <h3 align="center">
        侯烟存准【<b><u>{{case_evi_data.year}}</u></b>】第<b><u>{{case_evi_data.evi_id_number}}</u></b>号
      </h3>
      <div>
        <br><br>
      </div>
      <p>
        因 <b><u> {{ case_evi_data.mer_person }} </u></b> 涉嫌 <b><u>{{ case_evi_data.illegal_behavior }} </u></b>
        行为违反《中华人民共和国烟草专卖法》及实施条例等法律法规的有关规定，根据《中华人民共和国行政处罚法》
        第三十七条第二款的规定，现拟对下列物品予以先行登记保存：
      </p>
      <table border="1" style="border-collapse: collapse;" width="100%" >
        <tr>
          <th  width="25%">品种</th>
          <th  width="30%">条条形码</th>
          <th  width="25%">规格型号</th>
          <th  width="5%">单位</th>
          <th  width="10%">数量</th>
        </tr>
      </table>
      <div v-for="item in evidence_ciga_Data">
        <table border="1" style="border-collapse: collapse;" width="100%">
          <tr>
            <th  width="25%">{{item.ciga_variety}}</th>
            <th width="30%"> {{ item.barcode }}</th>
            <th  width="25%">{{ item.ciga_model }}</th>
            <th  width="5%">条</th>
            <th  width="10%">{{ item.evi_number }}</th>
          </tr>
        </table>
      </div>
      <table border="1" style="border-collapse: collapse;" width="100%">
        <tr>
          <th >
            <span style="text-align: left">共计： <b><u>{{ case_evi_data.tce_type_number_chinese }}</u></b>品种</span>
          </th>
          <th >
            <span style="text-align: right">总计： <b><u>{{ case_evi_data.tce_number_chinese }}</u></b></span>
          </th>
        </tr>
        <tr>
          <th>登记保存地点</th>
          <th>
            <b><u>{{case_evi_data.tce_address}}</u></b>
          </th>
        </tr>
      </table>
      <p style="font-size: 15px">
        登记保存证据的保存期限为七日。
      </p>
      <p style="font-size: 15px">
        承办人（签名）：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <b><u>&emsp;&emsp;&emsp;&emsp;{{case_evi_data.user_name_1}}&emsp;&emsp;&emsp;&emsp;</u></b><br>
        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <b><u>&emsp;&emsp;&emsp;&emsp;{{case_evi_data.user_name_2}}&emsp;&emsp;&emsp;&emsp;</u></b>
      </p>
      <p align="right" style="font-size: 15px">
        <b><u> {{ case_evi_data.year }}</u></b>年  <b><u>{{ case_evi_data.month }}</u></b> 月  <b><u>{{ case_evi_data.day }}</u></b> 日
      </p>
      </body>
      </html>
    </el-dialog>

    <!-- 编辑弹出框 -->
    <el-dialog title="证据先行保存通知书上传" v-model="Advice_note_Visible" width="30%">
      <el-form label-width="150px">
        <el-form-item label="案件号">
          <el-input :disabled="true" v-model="img_form_data.case_number"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="img_form_data.remark"></el-input>
        </el-form-item>
        <el-form-item label="点击上传证据照片" >
          <el-upload class="upload-demo"
                     action="#"
                     :limit=2
                     list-type="picture-card"
                     :on-change="handleChange"
                     :on-remove="handleRemove"
                     :on-preview="true"
                     :auto-upload="false"
                     :on-progress="true"
                     accept="bmp, jpg, png, gif, jpeg"
                     :show-file-list="true" >
            <el-icon class="el-icon--upload"><upload-filled /></el-icon>
          </el-upload>
        </el-form-item>
      </el-form>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Advice_note_Visible = false">取 消</el-button>
					<el-button type="primary" @click="certern_advice_note">确 定</el-button>
				</span>
      </template>
    </el-dialog>

    <el-dialog title="查看证据先行保存通知书" v-model="Advice_note_Views_Visible" width="30%">
      <el-image
          :src="img_form_data.img"
          :z-index="10"
          :preview-src-list="[img_form_data.img]"
          preview-teleported
      >
      </el-image>
      <template #footer>
				<span class="dialog-footer">
					<el-button @click="Advice_note_Views_Visible = false">取 消</el-button>
					<el-button type="primary" @click="Advice_note_Views_Visible = false">确 定</el-button>
				</span>
      </template>
    </el-dialog>

  </div>
</template>

<script setup lang="ts" name="basetable">
import { ref, reactive } from 'vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { Delete,Folder,Printer ,Document,Upload, Edit, Search, Plus } from '@element-plus/icons-vue';
import {
  case_evi_Create,
  case_evi_Views,
  case_legal_Create,
  ciga_evudence_Create,
  end_record_data,
  evi_Views,
  fetchData_case,
  fetchData_case_Create,
  fetchData_case_update,
  fetchData_legal_clause,
  fetchData_mer,
  fetchData_s_mongodb_evidence_Cre,
  fetchData_s_mongodb_evidence_Views,
  fetchData_tobacco,
  fetchData_user,
  illegal_record_data,
  illegal_record_Search,
  mer_Create,
  mer_search_api,
  review_price_data,
  staff_evidence_create,
  staff_evidence_data,
  end_record_show,
  record_inquiry_show,
  record_inquiry_print,
  case_evidence_Views, case_evidence_Edit
} from '../api/index';
import {
  export_word_1,
} from './table_inquiry.vue'

const user_number = localStorage.getItem('ms_username')

//案件表数据
interface TableItem {
  case_id:number,
  date_of_filing:string,
  date_of_closing:string,
  date_of_archive:string,
  case_source:string,
  case_number:string,
  archive_person:string,
  case_update_time:string,
  ase_type:string,
  case_remark:string,
  tcs_note_id:string,
  ciga_flag:string,
  ciga_num_flag:string,
  mer_flag:string,
}

//案件暂存数据
const create_case = reactive({
  staff_evi_id:0,
  staff_id:0,
  staff_evi_send_per:'',
  staff_evi_check_per1:'',
  staff_evi_check_per2:'',
  staff_evi_send_time:'',
  staff_evi_send_unit:'',
  staff_evi_send_result:'',
  staff_evi_rec_address:'',
  staff_evi_status:'',
  staff_evi_per_note:'',
  mer_flag:'',
  ciga_num_flag:'',
  ciga_flag:'',
  test:[],
  img_data:'',
  standard:'',
  tir_id:0,
  tlc_id:0,
  illegal_behavior:'',
  evi_id_number:'',
  date_of_filing:'',
  date_of_closing:'',
  date_of_archive:'',
  case_source:'',
  case_number:'',
  archive_person:'',
  case_update_time:'',
  case_type:'',
  case_remark:'',
  mer_id:0,
  tcs_note:'',
  case_id:0,
  tce_time:'',
  tce_number:0,
  tce_amount:0,
  tce_remark:'',
  tce_address:'福建省福州市闽侯县烟草专卖局',
  evi_number:0,//数量(条)
  ciga_variety:'',//品种
  barcode:'',//条形码
  ciga_model:'',//规格型号
  ciga_price:0,//单价
  inkjet:'',//
  mer_format:'',
  mer_address:'',
  mer_person:'',
  mer_record:'',
  date_of_record:'',
  date_of_effect:'',
  date_of_issue:'',
  mer_hometown:'',
  mer_id_number:'',
  mer_tel:'',
  business_licence_code:'',
  licence_state:'',
  storage_address:'',
  retail_licence_code:'',
  category:'',
  area_id:0,
  mer_zip_code:0,
  mer_name:'',
  remark:'',
});
//获取商户数据用作选项框
interface mer_data {
  mer_id: number,
  mer_format: string,
  mer_address: string,
  mer_person: string,
  mer_record: string,
  date_of_record: string,
  date_of_effect: string,
  date_of_issue: string,
  mer_hometown: string,
  mer_id_number: string,
  mer_tel: string,
  business_licence_code: string,
  licence_state: string,
  storage_address: string,
  retail_licence_code: string,
  category: string,
  area_id: number,
  mer_zip_code: number,
  mer_name: string,
}
const mer_Data = ref<mer_data[]>([]);
const get_mer_opinion = (mer_name:string='',licence_state:string='',mer_person:string='' ,mer_id:number,business_licence_code:string='') =>{
  fetchData_mer(mer_name,licence_state,mer_person,mer_id,business_licence_code).then(res =>{
    mer_Data.value = res.data.data;
  })
}
get_mer_opinion();
//获取执法人员数据作为选择框
interface staff_data{
  staff_id:number,
  staff_name:string,
  staff_gender:string,
  staff_birthday:string,
  staff_ethnicity:string,
  staff_edu_bg:string,
  staff_email:string,
  field_staff_identity_card:string,
  staff_hometown:string,
  staff_degree:string,
  staff_political_status:string,
  staff_post:string,
  staff_account_no:string,
  staff_account_pwd:string,
  staff_starting_time:string,
  staff_authorized:string,
  staff_phone:string,
  staff_tel:string,
  staff_e_sign:string,
  staff_small_number:string,
  staff_license_no:string,
  staff_now_work_degree:string,
  staff_now_evaluate_degree:string,
}
const staff_Data = ref<staff_data[]>([]);
const get_staff_opinion1 = () =>{
  fetchData_user('','','').then(res=>{
    staff_Data.value = res.data.data;
  })
}
get_staff_opinion1();

//获取案由信息数据用作选项框
interface illegal_data {
  tlc_id:number,
  illegal_behavior:string,
  standard:string,
  penalty_range:string,
  statutory_penalty:string,
  grade:string,
  remark:string,
}
const illegal_Data = ref<illegal_data[]>([]);
const get_legal_clause_opinion = (illegal_behavior:string='',standard:string='' ,grade:string='',tlc_id:number) =>{
  fetchData_legal_clause(illegal_behavior, standard,grade,tlc_id).then(res =>{
    illegal_Data.value = res.data.data;
  })
}
get_legal_clause_opinion();


//视图/

const Ratification_Visible_1 = ref(false);                              //批准书视图
const Ratification_Visible_2 = ref(false);                              //批准书视图
const Ratification_Edit_Visible = ref(false);                         //批准书修改视图
const Advice_note_Visible = ref(false);                               //通知书视图
const Advice_note_Views_Visible = ref(false);                         //查看通知书视图
const Ratification_View_Visible = ref(false);                         //查看批准书通知书视图

//通过案件号查询所有证据先行保存通知书
interface Evidence_case_data {
  case_id:number,//案件号
  evi_id_number:string,
  evi_number:number,
  tce_time_year:string,//案件时间
  tce_time_month:string,
  tce_time_day:string,
  tce_type_number:string,
  tce_number:string,
  tce_amount:number,
  tce_remark:string,
  tce_address:string,
}
const evidence_case_Data= ref<Evidence_case_data[]>([]);
const get_evidence_case_Data = (case_id:number) =>{
  case_evi_Views("" ,case_id).then(res=>{
    evidence_case_Data.value = res.data.data;
  })
}

//打印证据先行保存批准书
const create_evi_word = (row:any) =>{
  case_evidence_Views(row.case_id,row.evi_id_number).then(res=>{
    export_word_1(res.data.data.evi_id_number,
                  res.data.data.illegal_behavior,
                  res.data.data.mer_person,
                  res.data.data.year,
                  res.data.data.month,
                  res.data.data.day,
                  res.data.data.user_name_1, //执法人员1
                  res.data.data.user_name_2,//执法人员2
                  res.data.data.tce_type_number_chinese,
                  res.data.data.tce_number_chinese,
                  res.data.data.tce_address,
                  res.data.data.list
    )
  })
}

interface Evidence_ciga_data {
  case_id:number,
  evi_number:number,
  ciga_variety:string,
  barcode:string,
  ciga_model:string,
  ciga_price:number,
  inkjet:string,
  evi_id_number:string,
}
const evidence_ciga_Data= ref<Evidence_ciga_data[]>([]);
// 暂存先行保存批准书数据
const case_evi_data = reactive({
  date_of_filing:'',
  year:'',
  month:'',
  day:'',
  evi_id_number:'',
  evi_id_number1:'',
  illegal_behavior:'',
  tlc_id:'',
  mer_person:'',
  mer_id:'',
  tce_type_number:'',
  tce_number:'',
  tce_type_number_chinese:'',
  tce_number_chinese:'',
  tce_address:'',
  user_id_1:'',
  user_id_2:'',
  user_name_1:'',
  user_name_2:'',
})
//获取证据先行保存通知书中的信息
const get_case_evidenct_data = (row:any) =>{
  case_evidence_Views(row.case_id,row.evi_id_number).then(res=>{
        case_evi_data.date_of_filing = res.data.data.date_of_filing;
        case_evi_data.year = res.data.data.year
        case_evi_data.month = res.data.data.month
        case_evi_data.day = res.data.data.day
        case_evi_data.evi_id_number = res.data.data.evi_id_number
        case_evi_data.evi_id_number1 = res.data.data.evi_id_number
        case_evi_data.illegal_behavior = res.data.data.illegal_behavior
        case_evi_data.tlc_id = res.data.data.tlc_id
        case_evi_data.mer_person = res.data.data.mer_person
        case_evi_data.mer_id = res.data.data.mer_id
        case_evi_data.tce_type_number_chinese = res.data.data.tce_type_number_chinese
        case_evi_data.tce_number_chinese = res.data.data.tce_number_chinese
        case_evi_data.tce_type_number = res.data.data.tce_type_number
        case_evi_data.tce_number = res.data.data.tce_number
        case_evi_data.tce_address = res.data.data.tce_address
        case_evi_data.user_id_1 = res.data.data.user_id_1
        case_evi_data.user_id_2 = res.data.data.user_id_2
        case_evi_data.user_name_1 = res.data.data.user_name_1
        case_evi_data.user_name_2 = res.data.data.user_name_2
        evidence_ciga_Data.value = res.data.data.list
      }
  )

}
//修改证据先行保存通知书中的信息
const edit_case_evidenct_data = () =>{
  case_evidence_Edit(create_case.case_id,case_evi_data.evi_id_number1,case_evi_data.evi_id_number,
      case_evi_data.date_of_filing,case_evi_data.tlc_id,case_evi_data.mer_id,case_evi_data.tce_address,
      case_evi_data.user_id_1,case_evi_data.user_id_2).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('添加成功');
      get_evidence_case_Data(create_case.case_id);
      Ratification_Edit_Visible.value = false;
    }else {
      ElMessageBox.confirm('添加失败', '提示', {
        type: 'warning'
      })
    }
  })
}
const ratification_edit = (row:any) =>{

  get_case_evidenct_data(row)
  Ratification_Edit_Visible.value = true;
}
const ratification_view = (row:any) =>{

  get_case_evidenct_data(row)
  Ratification_View_Visible.value = true;
}
//只查看
const ratification_view_2 = () =>{

  Ratification_View_Visible.value = true;
}

//列表中的按钮
//证据先行保存通知书按钮
const ratification_tabel_1 = (row:any) =>{

  get_evidence_case_Data(row.case_id);
  create_case.case_id = row.case_id;
  Ratification_Visible_1.value = true;
}
//证据先行保存批准书审核按钮
const ratification_tabel_2 = (row:any) =>{
  get_evidence_case_Data(row.case_id);
  create_case.case_id = row.case_id;
  Ratification_Visible_2.value = true;
}

//证据先行保存通知书上传
const advice_note_tabel = (row:any) =>{
  create_case.case_id = row.case_id;
  img_form_data.case_number = row.case_number;
  Advice_note_Visible.value = true;
}
const certern_ratification = () =>{
    create_case.tcs_note = "证据先行保存批准书已完成"
    fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
      if (res.data.message === "success"){
        ElMessage.success('证据先行保存批准书已完成');
        getData();
        Ratification_Visible_1.value = false;
      }else {
        ElMessageBox.confirm('状态更新失败', '提示', {
          type: 'warning'
        })
      }
    })

}




const img_form_data = reactive({
  case_number: '',
  name:'',
  content:'',
  remark:'',
  img:'',
});
const img = [];
const handleChange = (file) =>{
  img.push(file);
}
const handleRemove = (file) =>{
  img.forEach(function (item,index,arr){
    if (item.name == file.name){
      img.splice(index,1)
    }
  })
}
const certern_advice_note = () =>{
  // ElMessage.success('证据先行保存通知书上传已完成');
  // Advice_note_Visible.value = false;
  // create_case.tcs_note = "证据先行保存通知书上传已完成"
  // fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
  //   if (res.data.message === "success"){
  //     ElMessage.success('状态更新成功');
  //     getData();
  //     //Ratification_Visible.value = false;
  //   }else {
  //     ElMessageBox.confirm('状态更新失败', '提示', {
  //       type: 'warning'
  //     })
  //   }
  //   });
  var form = new FormData();
  form.append('format',img[0].raw.type)
  form.append("file",img[0].raw)
  form.append("case_number",img_form_data.case_number)
  form.append("name","证据先行保存通知书")
  form.append("type","证据先行保存通知书")
  fetchData_s_mongodb_evidence_Cre(form).then(res=>{
    if (res.data.message === "success"){
      ElMessage.success('证据先行保存通知书上传已完成');
      Advice_note_Visible.value = false;
      create_case.tcs_note = "证据先行保存通知书上传已完成"
      fetchData_case_update(create_case.case_id,create_case.tcs_note).then(res=>{
        if (res.data.message === "success"){
          ElMessage.success('状态更新成功');
          getData();
          // Ratification_Visible.value = false;
        }else {
          ElMessageBox.confirm('状态更新失败', '提示', {
            type: 'warning'
          })
        }
      })
    }else {
      ElMessageBox.confirm('证据先行保存通知书上传失败', '提示', {
        type: 'warning'
      })
    }
  });
}

const advice_note_views = (row:any) =>{
  img_form_data.case_number = row.case_number;
  fetchData_s_mongodb_evidence_Views(row.case_number,"证据先行保存通知书").then(res => {
    img_form_data.img=res.data.data[0].img
    console.log(img_form_data.img)

  });
  Advice_note_Views_Visible.value=true;
}


const query = reactive({
  case_source:'',
  case_type:'',
  tcs_note_id:'',
  case_number:'',
  pageIndex: 1,
  pageSize: 10
});
const tableData = ref<TableItem[]>([]);
const tableList = ref<TableItem[]>([]); // 用于存放分页数据的列表
const pageTotal = ref(0);
const name = localStorage.getItem('ms_username');
// 获取表格数据
const getData = (archive_person:string='',case_id:number,case_source:string='',case_type:string='',case_number:string='',tcs_note_id:string='',name:string='') => {
  fetchData_case(archive_person,case_id,case_source,case_type,case_number,tcs_note_id,name).then(res => {
    tableData.value = res.data.data.filter((i: { tcs_note_id: string; }) =>(i.tcs_note_id =="证据采集已完成" ||
        i.tcs_note_id =="证据先行保存通知书上传已完成" ||
        i.tcs_note_id =="喷码记录表已完成" ||
        i.tcs_note_id =="立案报告表已完成" ||
        i.tcs_note_id =="立案报告表审核已完成" ||
        i.tcs_note_id =="卷烟鉴别书已完成" ||
        i.tcs_note_id =="涉案烟草价品核案表完成" ||
        i.tcs_note_id =="询问笔录已完成" ||
        i.tcs_note_id =="无证经营公示已完成" ||
        i.tcs_note_id =="现场勘验笔录已完成" ||
        i.tcs_note_id =="现场勘验笔录询问确认"||
        i.tcs_note_id =="立案报告表主任审核已完成"||
        i.tcs_note_id=="卷烟鉴别书已送检"||
        i.tcs_note_id=="调查终结文书已完成"||
        i.tcs_note_id=="案件处理审批已开始"||
        i.tcs_note_id=="集体讨论已开始"||
        i.tcs_note_id=="集体讨论已完成"||
        i.tcs_note_id=="听证已开始"||
        i.tcs_note_id=="听证告知书已完成"||
        i.tcs_note_id=="听证已完成"||
        i.tcs_note_id=="案件处理审批已完成"||
        i.tcs_note_id=="行政处罚事先告知书确认完成"||
        i.tcs_note_id=="行政处罚事先告知书已完成"||
        i.tcs_note_id=="行政处罚决定书确认完成"||
        i.tcs_note_id=="行政处罚决定书已完成"||
        i.tcs_note_id=="行政罚款收据上传完成"||
        i.tcs_note_id=="行政罚款收据已完成"||
        i.tcs_note_id=="结案报告表已完成"||
        i.tcs_note_id=="喷码记录表填写开始"||
        i.tcs_note_id=="已完成"||
        i.tcs_note_id=="撤案集体讨论准备"||
        i.tcs_note_id=="撤案集体讨论已开始"||
        i.tcs_note_id=="卷烟鉴别抽样单填写开始"||
        i.tcs_note_id=="卷烟鉴别委托书填写开始"||
        i.tcs_note_id=="上传送检结果开始"
        )  )
    tableList.value = [];
    pageTotal.value = tableData.value.length || 50;
    // 根据页码确定下标位置
    const index: number = query.pageIndex * query.pageSize - query.pageSize;
    for (let i = index; i < index + query.pageSize; i++) {
      // 防止数组下标越界
      if (i <= tableData.value.length - 1) {
        tableList.value.push(tableData.value[i])
      } else {
        // 越界就不再循环
        break;
      }
    }
  });
};
getData('','','','','','',name);
// 查询操作
const handleSearch = (case_number:string='',tcs_note_id:string='',case_source:string='',case_type:string='') => {
  getData('','',case_source,case_type,case_number,tcs_note_id,name);
};
// 分页导航
const handlePageChange = (val: number) => {
  query.pageIndex = val;
  getData('','','','','','',name);
};
</script>

<style scoped>
.handle-box {
  margin-bottom: 20px;
}

/*:deep .el-select-dropdown{*/
/*  max-width: 243px;*/
/*}*/
/*:deep .el-select-dropdown__item{*/
/*  display: inline-block;*/
/*}*/
/*.el-select-dropdown__item span {*/
/*  min-width: 205px;*/
/*  display: inline-block;*/
/*}*/


.handle-select {
  width: 120px;
}

.handle-input {
  width: 300px;
}
.table {
  width: 100%;
  font-size: 14px;
}
.red {
  color: #ff0000;
}

:deep(.avatar){
  width: 100px;
  height: 100px;
}
.blue {
  color: rgba(0, 118, 252, 0.79);
}
.mr10 {
  margin-right: 10px;
}
.table-td-thumb {
  display: block;
  margin: auto;
  width: 40px;
  height: 40px;
}
.handle-box button{
  background-color: #00a854;
}
/*#inspect_record{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -20px;*/

/*}*/

/*#filing_report_review{*/
/*  position: relative;*/
/*  left: 0px;*/
/*  top: -22px;*/
/*}*/
</style>
